package com.douxg.fastCoding.randomData;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

import java.util.List;
import java.util.Random;

/**
 * @Description
 * @Auther douxg
 * @Date 2020/11/12 13:04
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@Accessors(chain = true)
public class DictRandomData<T> implements RandomData<T> {
    private List<T> valus;

    @Override
    public T create() {
        if (valus == null || valus.size() == 0) {
            return null;
        }
        return valus.get(new Random().nextInt(valus.size()));
    }
}
